cmake_minimum_required(VERSION 3.10)
project(StaticInitDemo CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)   # -fPIC

# 1. 核心库（Registry 实现）
add_library(registry STATIC
    src/registry.cpp
)
target_include_directories(registry
    PUBLIC include
)

# 2. 插件动态库（包含静态初始化代码）
add_library(plugin 
    SHARED src/plugin.cpp
)
target_link_libraries(plugin PRIVATE registry)

# 3. 主程序
add_executable(driver
    src/driver.cpp
)
target_link_libraries(driver PRIVATE
    registry ${CMAKE_DL_LIBS})